package com.zdf.license.web.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ModelAndView bizExceptionHandler(HttpServletRequest request, Exception e){
        ModelAndView modelAndView = new ModelAndView("error/error");
        modelAndView.addObject("error", e.getMessage());
        modelAndView.addObject("message", e.getMessage());
        return modelAndView;
    }

}
